package com.huawei.controller;

import com.huawei.common.BaseResult;
import com.huawei.domain.Dept;
import com.huawei.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * @Author LF
 * projectName:vue-cli
 * description:
 * time:2025-04-26 20:14
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("/queryAllDept")
    public BaseResult<List<Dept>> queryAllDept() {
        List<Dept> deptList = deptService.queryAllDept();
        List<Dept> res = Optional.ofNullable(deptList).orElseThrow(() -> new RuntimeException("查询部门列表失败"));
        return BaseResult.success(res);
    }
}
